package seqlist.leetcode;

public class Num19删除链表中倒数第N个节点 {
    public ListNode removeNthFromEnd(ListNode head, int n) {
        ListNode prev = new ListNode();
        prev.next=head;
        ListNode fir = prev;
        ListNode cur = prev;
        while (n!=0){
            fir=fir.next;
            n--;
        }
        while (fir.next!=null){
            fir=fir.next;
            cur = cur.next;
        }

         cur.next=cur.next.next;
        return prev.next;
    }
}
